<#assign f = JspTaglibs["http://www.casic304.cn/f"] />
<div>
    <table id="wQbdAwardInformationTable" lay-filter="wQbdAwardInformationTable"></table>
    <form class="reportList-isShow">
        <input type="hidden" id="successDataId" name="successDataId">
    </form>
</div>
<!-- 右侧工具栏 -->
<script type="text/html" id="wQbdAwardInformationRightToolsBar">
    <a class="RightBtn" lay-event="particulars">详情</a>
</script>

<script>
    //一般直接写在一个js文件中
    layui.use(['table', 'form', 'common', 'publicMethods', 'jquery', 'layer'], function () {
        var table = layui.table;
        var common = layui.common;
        var publicMethods = layui.publicMethods;
        var $ = layui.jquery;
        var layer = layui.layer;

        var tableH=publicMethods.layerHeight();
        var dataId = "${dataId}";
        //第一个实例
        table.render({
            elem: '#wQbdAwardInformationTable'
            , height: tableH
            , url: serverPath.qbdmsPath + '/qbdms/wQbdAwardInformation/reportList?id=' + dataId + "&tableName=W_QBD_AWARD_INFORMATION"
            , method: 'post'
            , page: false //开启分页
            , autoSort: false //是否排序
            , cols: [[{field: 'sn', type: 'numbers', title: '序号', fixed: 'left', minWidth: 90},
                {type: 'checkbox', fixed: 'left'},
                {field: 'years', title: '年度',minWidth:90}
                , {field: 'awardOrg', title: '个人/单位',minWidth:110}
                , {field: 'awardPerson', title: '获奖人',minWidth:100}
                , {field: 'awardDept', title: '获奖单位',minWidth:110}
                , {field: 'awardName', title: '获奖名称',minWidth:110}
                //如需转换为:yyyy-MM-dd HH:mm:ss: return publicMethods.timeData(d.awardDate,"1");
                //如需转换为HH:mm:ss: return publicMethods.timeData(d.awardDate,"2");
                // 当前转换后的格式为yyyy-MM-dd: return publicMethods.timeData(d.awardDate);
                , {
                    field: 'awardDate', title: '获奖时间',minWidth:110,templet: function (d) {
                        return publicMethods.timeData(d.awardDate);
                    }
                }
                , {field: 'grantDept', title: '授奖单位',minWidth:110}, {
                    fixed: 'right',
                    title: '管理',
                    align:'center',
                    toolbar: '#wQbdAwardInformationRightToolsBar',
                    minWidth: 80
                }]], done: function () {
            }
        });

        table.on('tool(wQbdAwardInformationTable)', function (obj) {
            var data = obj.data, //获得当前行数据
                layEvent = obj.event; //获得 lay-event 对应的值
            switch (layEvent) {
                case "particulars":
                    var height=publicMethods.layHeight('body');
                    layer.open({
                        type: 2,
                        area: ['96%', height],
                        title: ['获奖信息'],
                        content: serverPath.qbdmsPath + '/qbdms/wQbdAwardInformation/view/particulars?id=' + data.id + "&isClose=true"
                    });
                    break;
            }
        });

        table.on('checkbox(wQbdAwardInformationTable)', function (obj) {
            if (obj.type == "all") {
                if (obj.checked) {
                    $("input[name='successDataId']").val("");
                    var checkStatus = table.checkStatus('wQbdAwardInformationTable');
                    var valArr = checkStatus.data;//选中行数据
                    var ceshiVal = $("input[name='successDataId']").val();
                    for (var i = 0; i < valArr.length; i++) {
                        ceshiVal = ceshiVal + valArr[i].id + ",";
                    }
                    $("input[name='successDataId']").val(ceshiVal);
                } else {
                    $("input[name='successDataId']").val("");
                }
            } else {
                if (obj.checked) {
                    var ceshiVal = $("input[name='successDataId']").val();
                    $("input[name='successDataId']").val(ceshiVal + obj.data.id + ",");
                } else {
                    var ceshiVal = $("input[name='successDataId']").val();
                    var newVal = "";
                    var valArr = ceshiVal.split(obj.data.id + ",");
                    for (var i = 0; i < valArr.length; i++) {
                        newVal += valArr[i];
                    }
                    $("input[name='successDataId']").val(newVal);
                }
            }
        });

    });
</script>
<!--</body>-->
<!--</html>-->